blob: 51c63b5a69de7eaded050f76f5a9e72b2f2c82c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import type { APIRoute } from "astro"
import { getCollection } from "astro:content"
export const GET: APIRoute = async ({ params }) => {
const slug = params.slug || "index"
const docs = await getCollection("docs")
const doc = docs.find((d) => d.id === slug)
if (!doc) {
return new Response("Not found", { status: 404 })
}
return new Response(doc.body, {
headers: {
"Content-Type": "text/plain; charset=utf-8",
},
})
}
|